let create _ =
  let table = Hashtbl.create 20 in
    Hashtbl.add table ' ' 1;
    Hashtbl.add table '`' 2;
    Hashtbl.add table '.' 3;
    Hashtbl.add table '\''4;
    Hashtbl.add table '_' 5;
    Hashtbl.add table '~' 6;
    Hashtbl.add table '-' 7;
    Hashtbl.add table ',' 8;
    Hashtbl.add table '=' 9;
    Hashtbl.add table '^' 10;
    Hashtbl.add table ':' 11;
    Hashtbl.add table 'i' 12;
    Hashtbl.add table '>' 13;
    Hashtbl.add table '<' 14;
    Hashtbl.add table '+' 15;
    Hashtbl.add table '!' 16;
    Hashtbl.add table '|' 17;
    Hashtbl.add table '*' 18;
    Hashtbl.add table ';' 19;
    Hashtbl.add table '{' 20;
    Hashtbl.add table '\\' 21;
    Hashtbl.add table '[' 22;
    Hashtbl.add table '7' 23;
    Hashtbl.add table 'l' 24;
    Hashtbl.add table ']' 25;
    Hashtbl.add table 'j' 26;
    Hashtbl.add table '"' 27;
    Hashtbl.add table '/' 28;
    Hashtbl.add table 'r' 29;
    Hashtbl.add table 't' 30;
    Hashtbl.add table '1' 31;
    Hashtbl.add table 'I' 32;
    Hashtbl.add table '?' 33;
    Hashtbl.add table 'v' 34;
    Hashtbl.add table '}' 35;
    Hashtbl.add table 'c' 36;
    Hashtbl.add table 'O' 37;
    Hashtbl.add table '(' 38;
    Hashtbl.add table ')' 39;
    Hashtbl.add table 'z' 40;
    Hashtbl.add table 'e' 41;
    Hashtbl.add table 's' 42;
    Hashtbl.add table 'a' 43;
    Hashtbl.add table 'f' 44;
    Hashtbl.add table '2' 45;
    Hashtbl.add table 'L' 46;
    Hashtbl.add table 'Y' 47;
    Hashtbl.add table 'u' 48;
    Hashtbl.add table '5' 49;
    Hashtbl.add table '&' 50;
    Hashtbl.add table 'n' 51;
    Hashtbl.add table 'k' 52;
    Hashtbl.add table 'C' 53;
    Hashtbl.add table '3' 54;
    Hashtbl.add table 'P' 55;
    Hashtbl.add table 'y' 56;
    Hashtbl.add table '%' 57;
    Hashtbl.add table 'J' 58;
    Hashtbl.add table 'T' 59;
    Hashtbl.add table 'w' 60;
    Hashtbl.add table 'x' 61;
    Hashtbl.add table '0' 62;
    Hashtbl.add table 'G' 63;
    Hashtbl.add table 'S' 64;
    Hashtbl.add table '8' 65;
    Hashtbl.add table 'Z' 66;
    Hashtbl.add table '9' 67;
    Hashtbl.add table '$' 68;
    Hashtbl.add table 'h' 69;
    Hashtbl.add table '6' 70;
    Hashtbl.add table 'o' 71;
    Hashtbl.add table 'd' 72;
    Hashtbl.add table 'g' 73;
    Hashtbl.add table 'p' 74;
    Hashtbl.add table 'q' 75;
    Hashtbl.add table 'D' 76;
    Hashtbl.add table 'b' 77;
    Hashtbl.add table 'A' 78;
    Hashtbl.add table 'V' 79;
    Hashtbl.add table 'R' 80;
    Hashtbl.add table '4' 81;
    Hashtbl.add table 'U' 82;
    Hashtbl.add table 'F' 83;
    Hashtbl.add table 'X' 84;
    Hashtbl.add table 'm' 85;
    Hashtbl.add table 'E' 86;
    Hashtbl.add table 'H' 87;
    Hashtbl.add table 'K' 88;
    Hashtbl.add table 'B' 89;
    Hashtbl.add table 'Q' 90;
    Hashtbl.add table '@' 91;
    Hashtbl.add table '#' 92;
    Hashtbl.add table 'N' 93;
    Hashtbl.add table 'M' 94;
    Hashtbl.add table 'W' 95;
    table

let compare a b =
  let table = create () in
    compare
      (Hashtbl.find table a)
      (Hashtbl.find table b)

let rec str_to_lst = function
      "" -> []
    | s ->
	(String.get s 0) ::
	  str_to_lst (String.sub s 1
			((String.length s) -1))

let rec lst_to_str = function
    [] -> ""
  | e::l -> String.make 1 e ^ (lst_to_str l)


let sort str =
  lst_to_str (List.sort compare
		(str_to_lst str))


